import 'package:flutter/material.dart';
import 'package:getx_scaffold/common/index.dart';
import 'package:oramemo/common/langs/text_key.dart';
import 'package:oramemo/core/controllers/auth_controller.dart';
import 'package:oramemo/core/controllers/profile_controller.dart';
import 'package:oramemo/core/models/api_response.dart';
import 'package:oramemo/pages/transcription/files/controllers/transcriptio_files_logic.dart';
import 'package:oramemo/widget/gradient_app_head.dart';
import 'package:oramemo/widget/gradient_background.dart';
import 'package:oramemo/widget/my_button.dart';

class FileAddPage extends StatelessWidget {
  final textController = TextEditingController();
  final TranscriptionFilesLogic controller = Get.find();

  FileAddPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: [
           GradientAppHead(
            title: TextKey.addFolderTitle.tr,
          ),
          Expanded(
            child: GradientBackground(
              child: Padding(
                padding: const EdgeInsets.fromLTRB(22.0, 29.0, 22.0, 16.0),
                child: Column(
                  children: [
                    Container(
                      decoration: BoxDecoration(
                        color: Colors.white,
                        borderRadius: BorderRadius.circular(12),
                      ),
                      child: TextField(
                        controller: textController,
                        decoration:  InputDecoration(
                          hintText: TextKey.folderNameHint.tr,
                          contentPadding: EdgeInsets.symmetric(
                            horizontal: 16,
                            vertical: 16,
                          ),
                          border: InputBorder.none,
                        ),
                        onChanged: (value) {
                          controller.update();
                        },
                        style: const TextStyle(
                          fontSize: 16,
                        ),
                      ),
                    ),
                    const SizedBox(height: 50),
                    GetBuilder<TranscriptionFilesLogic>(builder: (logic) {
                      return MyButton(
                        key: const Key('add'),
                        radius: 8,
                        onPressed: textController.text.isNotEmpty
                            ? () => _add()
                            : null,
                        text: TextKey.addButtonText.tr,
                      );
                    }),
                  ],
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }

  _add() {
    if (textController.text.isNotEmpty) {
      controller.addFolder(name: textController.text);
    } else {
      Toast.show(TextKey.nicknameEmptyError.tr);
    }
  }
}
